package com.cskaoyan.javase.basic._8loop;

/**
 * 嵌套循环
 * 以for循环为例
 *
 * 打印以下图案
 *      #
 *      ##
 *      ###
 *      ####
 *      #####
 *
 * 打印九九乘法表
 *
 * @since 09:54
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo3 {
    public static void main(String[] args) {
        // 嵌套for打印图案,外层for控制行数,内层for控制列数
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print("#");
            }
            System.out.println();
        }

        System.out.println("-----------------------------------------");
        // 打印九九乘法表
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i + " * " + j + " = " + (i * j) + "\t");
            }
            System.out.println();
        }
    }
}
